<template>
	<view  class="pages">
		<my-header bgCol="#0000" :isHome="isHome" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content"></block>
		</my-header>
        <video v-if="videoInfo.video_url" :src="videoInfo.video_url" autoplay loop :show-fullscreen-btn="false" :style="videoSty" @loadedmetadata="loaded"></video> 
        <view class="col">
             <view class="down col" v-if="videoInfo.down_link" @click="download(videoInfo.down_link)">下载视频</view>
        </view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
                videoInfo:{},
                videoSty:"",
                content:"",
                links:"",
                isHome:0
			}
		}, 
		onLoad(options){
            // this.initData()
            // options.link="82e2c219e8d9b3fc57d8450b682c3fcf"
            this.isHome=1
            this.initData(options.link)
        },
        onShareAppMessage(){
            let url='/videoLogo/pages/details?isHome=1&link='+this.videoInfo.token
                // uni.navigateTo({
                //     url
                // });
            return {
                title:this.videoInfo.desc,
                imageUrl:this.videoInfo.img_url,
                path:url,
                success: function (res) {}, 
            }
        },
		methods: {
			async initData(url){
                const res=await uni.$request({
                    token: url
                },"api/api/doucheck")
                if (res.code==200) {
                    this.videoInfo=res.data
                }else{
                    uni.$err(res.msg)
                }
            },
            async getLinks(links=""){
                const res=await uni.$request({
                    links,
                },"api/api/get_surl")
                this.links=res.data.url
            },
            loaded(e){
                let data=e.detail
                let w=650;
                let flg=data.width/data.height
                this.videoInfo={
                    ...this.videoInfo,
                    ...data
                }
                // this.videoSty="width:"+w+"rpx;height:"+w/flg+"rpx"
            },
            copy(){
                uni.$copy(this.links)
            },
            download(links){
                uni.downloadFile({
                    url: uni.$url+links, //仅为示例，并非真实的资源
                    success: (res) => {
                        console.log(res);
                        console.log(res.tempFilePath);
                        if (res.statusCode === 200) {
                            console.log('下载成功');
                        }
                    },
                    fail:(err)=>{
                        console.log(err);
                    }
                });
            }
			
			
		}
	}
</script>

<style lang="scss">
	video{
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0rpx;
    }
    .down{
        position: fixed;
        bottom: 400rpx;
        z-index: 9999999999991;
        width: 300rpx;
        height: 80rpx;
        border-radius: 100rpx;
        -webkit-box-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
        background: $main_col;
        color: #fff;
    }
</style>